package com.wee.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.android.volley.toolbox.ImageLoader;
import com.wee.aircoach_user.MyApplication;
import com.wee.aircoach_user.R;

import java.util.List;

/**
 * Created by xiaobing on 15/8/17.
 * 教练注册里面， 职业类型，擅长领域
 */
public class CoachImgsAdapter extends BaseAdapter{
    private Context context;
    private List<String> data;

    public CoachImgsAdapter(Context context, List<String> data) {
        this.context = context;
        this.data = data;
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder ;
        if(convertView==null){
            holder = new ViewHolder();
            LayoutInflater inflate = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflate.inflate(R.layout.item_coach_imgs, null);
            holder.img = (ImageView)convertView.findViewById(R.id.img);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder)convertView.getTag();
        }
        String path = data.get(position);
        MyApplication.getInstance().getImageLoader().get(path, ImageLoader.getImageListener(holder.img, R.drawable.coach_nophoto, R.drawable.coach_nophoto),400,400);
        return convertView;
    }
    static class ViewHolder{
        ImageView img;
    }
}